package com.gxa.customer.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gxa.common.commons.R;
import com.gxa.common.params.HousePaymentStatusUpdateParam;
import com.gxa.common.params.QueryHousePaymentStatusParam;
import com.gxa.common.pojo.HousePaymentStatus;
import com.gxa.common.utils.RUtils;
import com.gxa.customer.mapper.HousePaymentStatusMapper;
import com.gxa.customer.service.HousePaymentStatusService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HousePaymentStatusServiceImpl implements HousePaymentStatusService {
    @Autowired
    private HousePaymentStatusMapper housePaymentStatusMapper;
    @Override
    public R updateHousePaymentStatus(HousePaymentStatusUpdateParam param) {
        HousePaymentStatus housePaymentStatus = new HousePaymentStatus();
        BeanUtils.copyProperties(param,housePaymentStatus);
        housePaymentStatusMapper.updateById(housePaymentStatus);
        return RUtils.success();
    }

    @Override
    public R queryHousePaymentStatus(QueryHousePaymentStatusParam param) {
        QueryWrapper<HousePaymentStatus> wrapper = new QueryWrapper<>();
        wrapper.eq("nation_id",param.getNationId()).eq("customer_id",param.getCustomerId());
        List<HousePaymentStatus> list = housePaymentStatusMapper.selectList(wrapper);
        return RUtils.success(list);
    }
}
